//
//  BaseTableViewController.swift
//  sinaOnceAgain
//
//  Created by 王相超 on 16/2/16.
//  Copyright © 2016年 chuanzhi. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {
    
    
    //用户是否登录的标记
    var userLogin = UserAccountViewModel.sharedAccountViewModel.userLogin
    
    //访客视图属性
    var visitorLoginView: VisitorLoginView?

    //准备视图控制器的跟视图
    override func loadView() {
        
        if userLogin {
            
            super.loadView()
        }else {
            
            //显示自定义的访客视图  引导用户登录或者注册
            visitorLoginView = VisitorLoginView()
            
            //指定代理
            visitorLoginView?.visitorLoginViewDelegate = self
        
            view = visitorLoginView
            
            //设置导航按钮
            navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
            navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWilRegister")
        }
   }
    
    //实现代理方法
    func userWillLogin() {
        
        let oauth = OAuthViewController()
        
        let nav = UINavigationController(rootViewController: oauth)
        
        presentViewController(nav, animated: true , completion: nil)
    }
    
    func userWillRegister() {
        print(__FUNCTION__)
    }

    override func viewDidLoad() {
        super.viewDidLoad()

   
    }

 

}
